﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace M3G {
    public class World : Group {
        #region Field
        Background background;
        Camera     activeCamera;
        #endregion

        #region Method
        public World () {
            this.background = null;
            this.activeCamera = null;
        }

        protected World (World world)
            : base (world) {
            this.background = world.background;
            this.activeCamera = world.activeCamera;
        }

        public Camera ActiveCamera {
            get { return activeCamera; }
        }

        public void SetActiveCamera (Camera camera) {
            this.activeCamera = camera;
        }

        public Background Background {
            get { return background; }
        }

        public void SetBackground (Background background) {
            this.background = background;
        }

        public override Object3D[] References {
            get {
                var q = new List<Object3D> ();
                q.AddRange (base.References);
                q.Add (background);
                q.Add (activeCamera);
                q.RemoveAll (x => x == null);
                return q.ToArray ();
            }
        }

        public override Object3D Duplicate () {
            var wld = new World (this);
            wld.parent = null;
            return wld;
        }
        #endregion

    }
}
